// pages/index/search/search.js
var test1={
 
}
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list_s: [{ 'title': '卡地亚'}],
    history: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },
  // 清空
  qingkong:function(){
    wx.setStorageSync('test1', "")
    var that = this
    that.setData({
      list_s: wx.getStorageSync("test1")
    })
  },
  shanchu:function(e){
    var t = wx.getStorageSync("test1")
    var id = e.currentTarget.id
    t.splice(id, 1)
    wx.setStorageSync('test1', t)
    wx.getStorageSync("test1")
    var that = this 
    that.setData({   
      list_s: wx.getStorageSync("test1")
    })
  },
  gotojieguo:function(e){
    var id = e.currentTarget.dataset.name
    wx.navigateTo({
      url: 'search_jg/search_jg?id='+id,
      
    })
  },
  gotojieguos:function(e){
    var that = this
    var id = e.detail.value
    let arr = wx.getStorageSync("test1") || [];
    arr.unshift(id);
    let result = []
    let obj = {}
    for (let i of arr) {
      if (!obj[i]) {
        result.push(i)
        obj[i] = 1
      }
    }
    wx.setStorageSync("test1", result)
    var test1 = wx.getStorageSync("test1")
    that.setData({
      list_s: wx.getStorageSync("test1")
    })
    if(id != ""){
      wx.navigateTo({
         url: 'search_jg/search_jg?id=' + id,
      })
    }   
  },
  // 键盘抬起事件
  inputTyping:function(e){
    console.log(e.detail.value)
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  quxiao:function(){
    wx.navigateBack({
      delta: 1,
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var i =  wx.getStorageSync("test1")
    this.setData({
      list_s: wx.getStorageSync("test1")
    })
    // htat.setData({
    //   list_s:value
    // })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})